import { get, post } from '@/utils/request';

// 定义工具表单规则类型
export interface ToolFormRule {
  name: string;
  rows: number;
  type: string;
  options?: string;
  unit?: string;
  remark?: string;
  displayorder: number;
}

// 定义工具详情类型
export interface ToolDetail {
  id: number;
  name: string;
  form_rule: ToolFormRule[];
}

// 获取工具详情接口
export const getToolDetail = (id: number) => get<ToolDetail>(`/system/tools/${id}`).json();

// 提交工具表单数据接口
export function submitToolForm(id: number, data: Record<string, any>) {
  return post<{ code: number; message: string }>(`/system/tools/${id}`, data).json();
}
